<template>
  <div>
    <button @click="getStudents">点击获得学生信息</button>
    <button @click="getCars">点击获得汽车信息</button>
  </div>
</template>

<script>
//导入axios
import axios from "axios";
export default {
  name: "get-students",
  methods:{
    getStudents() {
      axios.get('http://localhost:8080/cty/students').then(response => {
        console.log('连接成功 获取数据',response.data);
      },err => {
        console.log('连接失败',err.message)
      })
    },
    getCars() {
      axios.get('http://localhost:8080/demo/cars').then(response => {
        console.log('连接成功 获取数据',response.data);
      },err => {
        console.log('连接失败',err.message)
      })
    }
  }
}
</script>

<style scoped>

</style>